
var usr_list_BT=""
		+"<div class='w3-container'>\n"
		+"	<div class='w3-row  w3-btn '  style='background-color:#eee;width:100%;' onclick= BT_connect(0);  '>\n"
			+"	<div class='w3-col s9 w3-container'>\n"
				+"	<h4    class='w3-text-teal  '>";
var usr_list_end=""
			+"</h4 >\n"
				+"</div>\n"
			+"</div>  \n"		
		+"</div> ";

	function initialize()
	{
		 

	}
		function JavacallJS(receive_str)
		{
				
			var i=receive_str.indexOf(";BTalive");
			if(i>0)
			{
				var liveid=receive_str.substr(0,i);
				add_user_BT(liveid);
			}
			

		}

		function car_run(cmd)
		{
			window.call_java.JScallJava('bluetooth',cmd+";\r\n");
		}



		function BT_search()
		{
		 //add_user_BT("RSheep1");
			 $('#bt_status_gif1').addClass('loading');
			 $('#bt_status_gif').text('');
		 	 
			window.call_java.JScallJava('bluetooth','bluetooth scan');
	
		}
		function BT_connect(nx)
		{
			//connect to bluetooth
			 $('#bt_status_gif1').removeClass('loading');
			$('#bt_status_gif').text(''); 
			 $('#bt_status_gif1').text('Connected');
			window.call_java.JScallJava('bluetooth','bluetooth connect'+nx);
			//disconnect to bluetooth
			///window.call_java.JScallJava('bluetooth','bluetooth disconnect');
			 
		}


		function add_user_BT(new_id)
		{
			var i=0,j=0;
			if(new_id=="")
				return;

			j=new_id.indexOf("RSheep");
			if(j>=0)
			{
				var htmlw=$('#BT_list').html();
				//$('#BT_list').html(htmlw+usr_list_BT+new_id+usr_list_end);
				$('#BT_list').html(usr_list_BT+new_id+usr_list_end);
			}
	
		}

function BT_send_T(value)
{
	window.call_java.JScallJava('bluetooth',value+';\r\n'); 
}


function  ima_car(cmd_l,cmd_r)
{
	BT_send_T(cmd_l);
	setTimeout("BT_send_T('"+cmd_r+"');",80);
	//window.call_java.JScallJava('bluetooth',cmd_l+';\r\n'); 
	//window.call_java.JScallJava('bluetooth',cmd_r+';\r\n'); 
}
		
